package app.kotlin_1.base

import android.support.v7.widget.RecyclerView
import android.util.SparseArray
import android.view.View



/**
 * Created by 刘智强 on 2017/9/22.
 */
class BaseViewHolder : RecyclerView.ViewHolder {
    private var views: SparseArray<View>? = null

    constructor(itemView: View?) : super(itemView) {
        this.views = SparseArray<View>()

    }

    fun <T : View> getView(viewId: Int): T {
        var view = views?.get(viewId)
        if (view == null) {
            view = itemView.findViewById(viewId)
            views?.put(viewId, view)
        }
        return view as T
    }

    fun getRootView(): View {
        return itemView
    }

}